/*******************************************************************************
 * FilePath    : /Software/Examples_Ble_MS1642/ble_app_peripheral_OTA_code/main.c
 * Version     : 1.0
 * Brief       :
 * Author      : AndrewHu
 * Company     : Shanghai MacroGiga Electronics CO.,Ltd
 * Email       : Hubinbo@macrogiga.com
 * Date        : 2020-04-03 15:06:14
 * LastEditors : AndrewHu
 * LastEditTime: 2023-05-23 11:44:10
 * Description :
 ******************************************************************************/
/* Includes ------------------------------------------------------------------*/
#include <Includes.h>
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function ----------------------------------------------------------*/
/* extern --------------------------------------------------------------------*/
/*******************************************************************************
 * Function    : main
 * Brief       : 主函数
 * Parameter   :
 * Returns     :
 * Date        : 2020-04-03 17:14:47
 * Description :
 ******************************************************************************/
int main(void)
{
    u32 UnitDelay = 0x2000;

    while (UnitDelay--)
        ; // wait a while for hex programming if using the MCU stop mode, default NOT used.

    BSP_Init(); // 硬件初始化
    Ble_Init(); // 蓝牙初始化
    Uart_Send_String((u8 *)"\r\nIND:Ble Init OK!", 18);
    UnitDelay = GetSysTickCount(); // 获取滴答时钟时间，1ms累计
    while (1)
    {
        IrqMcuGotoSleepAndWakeup(); // 蓝牙休眠判定，蓝牙工作方式为间断式工作

        if ((GetSysTickCount() - UnitDelay) >= 10)
        { // 10ms计时
            UnitDelay = GetSysTickCount();
            Fun_Uart_Run(); // 串口扫描
        }
    }
}
